package com.intellagric.controller.module.ift_ctrl_equipment;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.iftmonitor.CtrlEquipmentChannelVo;
import com.intellagric.pojo.IftCtrlEquipmentButton;
import com.intellagric.pojo.IftCtrlEquipmentChannel;
import com.intellagric.service.iftmonitor.ift_ctrl_equipment.CtrlEquipmentButtonService;
import com.intellagric.service.iftmonitor.ift_ctrl_equipment.CtrlEquipmentChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/12/13
 * @DESC： 控制设备通道按钮管理
 */
@Controller
public class CtrlEquipmentButtonController {

    @Autowired
    private CtrlEquipmentButtonService ctrlEquipmentButtonService;

    /**
     * 添加控制设备通道按钮信息
     * @Param ctrlEquipmentChannel
     * @return ResponseMessage
     */
    @RequestMapping("/ctrlequipment/button/add")
    @ResponseBody
    public ResponseMessage add(IftCtrlEquipmentButton ctrlEquipmentChannel) {
        ctrlEquipmentChannel.setId(UUID.randomUUID().toString().replaceAll("-",""));
        ctrlEquipmentChannel.setCreateDate(new Date());
        ctrlEquipmentChannel.setUpdateDate(new Date());
        return ctrlEquipmentButtonService.addCtrlEquipmentButton(ctrlEquipmentChannel);
    }


    /**
     * 删除控制设备通道按钮信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/ctrlequipment/button/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return ctrlEquipmentButtonService.deleteCtrlEquipmentButton(id);
    }

    /**
     * 修改控制设备通道按钮信息
     * @Param ctrlEquipmentChannel
     * @return ResponseMessage
     */
    @RequestMapping("/ctrlequipment/button/edit")
    @ResponseBody
    public ResponseMessage edit(IftCtrlEquipmentButton ctrlEquipmentButton) {
        ctrlEquipmentButton.setUpdateDate(new Date());
        return ctrlEquipmentButtonService.editCtrlEquipmentButton(ctrlEquipmentButton);
    }

    /**
     * 查询控制设备通道按钮信息
     * @return IftCtrlEquipmentChannel
     */
    @RequestMapping("/ctrlequipment/button/{id}")
    @ResponseBody
    public IftCtrlEquipmentButton get(@PathVariable String id) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonById(id);
    }

    /**
     * 查询控制设备id查询按钮信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/ctrlequipment/button/list")
    @ResponseBody
    public LayuiDataGridResult getList(String ctrlEquipmentId) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonList(ctrlEquipmentId);
    }

    /**
     * 多条件控制设备通道信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/ctrlequipment/button/query")
    @ResponseBody
    public LayuiDataGridResult getPage(IftCtrlEquipmentButton ctrlEquipmentButton) {
        return ctrlEquipmentButtonService.getCtrlEquipmentButtonListByVo(ctrlEquipmentButton);
    }

}
